package com.yy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yy.domain.PayContractFee;
import com.yy.service.IPayContractFeeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yy.common.annotation.Log;
import com.yy.common.core.controller.BaseController;
import com.yy.common.core.domain.AjaxResult;
import com.yy.common.enums.BusinessType;


import com.yy.common.utils.poi.ExcelUtil;
import com.yy.common.core.page.TableDataInfo;

/**
 * 合同收费项目Controller
 * 
 * @author yy
 * @date 2023-10-30
 */
@RestController
@RequestMapping("/system/fee")
public class PayContractFeeController extends BaseController
{
    @Autowired
    private IPayContractFeeService payContractFeeService;

    /**
     * 查询合同收费项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:fee:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayContractFee payContractFee)
    {
        startPage();
        List<PayContractFee> list = payContractFeeService.selectPayContractFeeList(payContractFee);
        return getDataTable(list);
    }

    /**
     * 导出合同收费项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:fee:export')")
    @Log(title = "合同收费项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayContractFee payContractFee)
    {
        List<PayContractFee> list = payContractFeeService.selectPayContractFeeList(payContractFee);
        ExcelUtil<PayContractFee> util = new ExcelUtil<PayContractFee>(PayContractFee.class);
        util.exportExcel(response, list, "合同收费项目数据");
    }

    /**
     * 获取合同收费项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(payContractFeeService.selectPayContractFeeById(id));
    }

    /**
     * 新增合同收费项目
     */
    @PreAuthorize("@ss.hasPermi('system:fee:add')")
    @Log(title = "合同收费项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayContractFee payContractFee)
    {
        return toAjax(payContractFeeService.insertPayContractFee(payContractFee));
    }

    /**
     * 修改合同收费项目
     */
    @PreAuthorize("@ss.hasPermi('system:fee:edit')")
    @Log(title = "合同收费项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayContractFee payContractFee)
    {
        return toAjax(payContractFeeService.updatePayContractFee(payContractFee));
    }

    /**
     * 删除合同收费项目
     */
    @PreAuthorize("@ss.hasPermi('system:fee:remove')")
    @Log(title = "合同收费项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(payContractFeeService.deletePayContractFeeByIds(ids));
    }
}
